clear all
load ParEst_eh1_time0_Mex
load ParEst_eh1_time0_Mex_allboots
load ParEst_eh1_time1_Mex
load ParEst_eh1_time1_Mex_allboots

ParEst_eh1_time0_Mex_allboots(:,21)=10.^ParEst_eh1_time0_Mex_allboots(:,21);

Par1 = [ParEst_eh1_time0_Mex,ParEst_eh1_time1_Mex]'; % estimates
Par2 = [std(ParEst_eh1_time0_Mex_allboots(:,1:end-1)),std(ParEst_eh1_time1_Mex_allboots(:,1:end-1))]'; % bootstrap estimates

Par1(21) = 10^(Par1(21)); 
Par1(22:27) = Par1(22:27)*1000;
Par1(30:31) = 500*Par1(30:31);
Par2(22:27) = Par2(22:27)*1000;
Par2(30:31) = 500*Par2(30:31);

alphaf=Par1(17);
betaf=Par1(18);
alphai=Par1(19);
betai=Par1(20);
theta=Par1(21);
a_h=Par1(22);
b1_h = Par1(23); 
b2_h = Par1(24);
a_l=Par1(25);
b1_l = Par1(26); 
b2_l = Par1(27);
nu_hl= Par1(28); nu_lh = Par1(29);
gamma_h = Par1(30);
gamma_l = Par1(31);
alphaf_2=Par1(32);
betaf_2=Par1(33);
alphai_2=Par1(34);
betai_2=Par1(35);

sd_alphaf=Par2(17);
sd_betaf=Par2(18);
sd_alphai=Par2(19);
sd_betai=Par2(20);
sd_theta=Par2(21);
sd_a_h=Par2(22);
sd_b1_h = Par2(23); 
sd_b2_h = Par2(24);
sd_a_l=Par2(25);
sd_b1_l = Par2(26); 
sd_b2_l = Par2(27);
sd_nu_hl= Par2(28); sd_nu_lh = Par2(29);
sd_gamma_h = Par2(30);
sd_gamma_l = Par2(31);
sd_alphaf_2=Par2(32);
sd_betaf_2=Par2(33);
sd_alphai_2=Par2(34);
sd_betai_2=Par2(35);

load MWP_a_h MWP_a_h
load MWP_a_l MWP_a_l
load MWP_gamma_h MWP_gamma_h
load MWP_gamma_l MWP_gamma_l
load MWP_a_boot_h MWP_a_boot_h
load MWP_a_boot_l MWP_a_boot_l
load MWP_gamma_boot_h MWP_gamma_boot_h
load MWP_gamma_boot_l MWP_gamma_boot_l
sd_MWP_a_h=std(MWP_a_boot_h);
sd_MWP_a_l=std(MWP_a_boot_l);
sd_MWP_gamma_h=std(MWP_gamma_boot_h);
sd_MWP_gamma_l=std(MWP_gamma_boot_l);

%Contact rates
Transitions_both = {'F-N';''; 'I-N';''; 'N-F';''; 'N-I';''; 'F-I';''; 'I-F';''; 'p1';''; 'q1';'';''; 'F-N';''; 'I-N';''; 'N-F';''; 'N-I';''; 'F-I';''; 'I-F';''; 'p2';''; 'q2';''; 'phl_rate';''; 'plh_rate';''};
Estimates = [Par1(1); Par2(1); Par1(2); Par2(2); Par1(3); Par2(3); Par1(4); Par2(4); Par1(5); Par2(5); Par1(6); Par2(6); Par1(13); Par2(13); Par1(14); Par2(14);NaN;Par1(7); Par2(7); Par1(8); Par2(8); Par1(9); Par2(9); Par1(10); Par2(10); Par1(11); Par2(11); Par1(12); Par2(12); Par1(15); Par2(15); Par1(16); Par2(16);Par1(28);Par2(28);Par1(29);Par2(29)];
Transition_Rates_table = table(Transitions_both, Estimates);
writetable(Transition_Rates_table, 'Transition_Rates_table.xls')

%Preference parameters
Preference = {'theta';'';'b1_h';'';'b1_l';'';'b2_h';'';'b2_l';'';'a_h';'';'a_l';'';'gamma_h';'';'gamma_l';'';'MWP a_h';'';'MWP a_l';'';'MWP gamma_h';'';'MWP gamma_l';''};
Estimates = [theta; sd_theta; b1_h; sd_b1_h;b1_l; sd_b1_l; b2_h; sd_b2_h;b2_l; sd_b2_l; a_h; sd_a_h;a_l; sd_a_l; gamma_h; sd_gamma_h; gamma_l; sd_gamma_l;MWP_a_h; sd_MWP_a_h; MWP_a_l; sd_MWP_a_l;MWP_gamma_h; sd_MWP_gamma_h;MWP_gamma_l; sd_MWP_gamma_l];
Preferences_table = table(Preference, Estimates);
writetable(Preferences_table, 'Preferences_table.xls')

%Wage offer parameters
Wage_offer = {'alpha_formal';'';'beta_formal';'';'alpha_informal';'';'beta_informal';''};
Estimates = [alphaf; sd_alphaf; betaf; sd_betaf; alphai; sd_alphai; betai; sd_betai];
Wage_offer_par_table = table(Wage_offer, Estimates);
writetable(Wage_offer_par_table, 'Wage_offer_par_table.xls')

%Wage offer parameters
Wage_offer = {'alpha_formal';'';'beta_formal';'';'alpha_informal';'';'beta_informal';''};
Estimates = [alphaf_2; sd_alphaf_2; betaf_2; sd_betaf_2; alphai_2; sd_alphai_2; betai_2; sd_betai_2];
Wage_offer_par_table = table(Wage_offer, Estimates);
writetable(Wage_offer_par_table, 'Wage_offer_par_table_2nd_stage.xls')

